package com.atguigu.lease.admin.controller;

import com.atguigu.lease.admin.service.PaymentTypeService;
import com.atguigu.lease.pojo.PaymentType;
import com.atguigu.lease.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/admin/payment")
@RestController
@Tag(name = "支付方式管理模块")
public class PaymentTypeController {
    @Autowired
    private PaymentTypeService paymentTypeService;

    @Operation(summary = "查询所有支付方式")
    @GetMapping("/list")
    public Result<List<PaymentType>> list() {
        List<PaymentType> list = paymentTypeService.list();
        return Result.success(list);
    }

    @Operation(summary = "新增或更新支付方式")
    @PostMapping("/saveOrUpdate")
    public Result<Boolean> saveOrUpadate(@RequestBody PaymentType paymentType) {
        boolean b = paymentTypeService.saveOrUpdate(paymentType);
        return Result.success(b);
    }

    @Operation(summary = "根据id删除支付方式")
    @DeleteMapping("/deleteById")
    public Result<Boolean> deleteById(@RequestParam("id") Long id) {
        boolean b = paymentTypeService.removeById(id);
        return Result.success(b);
    }
}
